#!/bin/sh
#set -x
#set -o errexit
c_files=*.c
cpp_files=*.cpp
if [ $# -gt 0 ] ; then
    base=`basename $1 .c`
    echo "==> compiling $base"
    gcc -ggdb $base.c -o $base `pkg-config opencv --cflags --libs`
else
    if [ -n "$c_files" ] ; then
        for i in *.c; do
            echo "==> compiling $i"
            gcc -ggdb -o `basename $i .c` $i `pkg-config --libs --cflags opencv`;
    done
    elif [ -n "$cpp_files" ] ; then
    for i in *.cpp; do
        echo "==> compiling $i"
        g++ -ggdb -o `basename $i .cpp` $i `pkg-config --libs --cflags opencv`;
    done
    else
        echo "***no .c or .cpp source code file found***"
        exit 1
    fi
fi
